home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Kant Generator Pro 1.0.1 / source / Shell ƒ / graphics dispatch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  8.9 KB  |  480 lines  |  [TEXT/MMCC]

  1. #include "graphics dispatch.h"
  2. #include "window layer.h"
  3. #include "program globals.h"
  4. #include "edit functions.h"
  5. #include "text twiddling.h"
  6. #include "generic window handlers.h"
  7. #include "about.h"
  8. #include "about MSG.h"
  9. #include "other MSG window.h"
  10. #include "help.h"
  11. #include "kant main window.h"
  12. #include "kant build window.h"
  13.  
  14. enum DispatchError SetupWindowDispatch(short index, WindowPtr theWindow)
  15. {
  16.     SetWindowIndex(theWindow, index);
  17.     SetWindowTE(theWindow, 0L);
  18.     SetWindowVScrollBar(theWindow, 0L);
  19.     SetWindowHScrollBar(theWindow, 0L);
  20.     
  21.     switch (index)
  22.     {
  23.         case kAboutWindow:
  24.             SetupTheAboutWindow(theWindow);
  25.             return kSuccess;
  26.         case kAboutMSGWindow:
  27.             SetupTheAboutMSGWindow(theWindow);
  28.             return kSuccess;
  29.         case kOtherMSGWindow:
  30.             SetupTheOtherMSGWindow(theWindow);
  31.             return kSuccess;
  32.         case kHelpWindow:
  33.             SetupTheHelpWindow(theWindow);
  34.             return kSuccess;
  35.         case kMainWindow:
  36.             SetupTheMainWindow(theWindow);
  37.             return kSuccess;
  38.         case kBuildWindow:
  39.             SetupTheBuildWindow(theWindow);
  40.             return kSuccess;
  41.     }
  42.     
  43.     return kFailure;
  44. }
  45.  
  46. enum DispatchError ShutdownWindowDispatch(short index)
  47. {
  48.     switch (index)
  49.     {
  50.         case kAboutWindow:
  51.             ShutDownTheAboutWindow();
  52.             return kSuccess;
  53.         case kAboutMSGWindow:
  54.             ShutDownTheAboutMSGWindow();
  55.             return kSuccess;
  56.         case kHelpWindow:
  57.             ShutDownTheHelpWindow();
  58.             return kSuccess;
  59.         case kMainWindow:
  60.             ShutDownTheMainWindow();
  61.             return kSuccess;
  62.     }
  63.     
  64.     return kFailure;
  65. }
  66.  
  67. enum DispatchError OpenWindowDispatch(short index)
  68. {
  69.     WindowPtr        theWindow;
  70.     
  71.     theWindow=GetIndWindowPtr(index);
  72.     
  73.     switch (index)
  74.     {
  75.         case kAboutWindow:
  76.             OpenTheAboutWindow(theWindow);
  77.             return kSuccess;
  78.         case kAboutMSGWindow:
  79.             OpenTheMSGWindow(theWindow);
  80.             return kSuccess;
  81.         case kOtherMSGWindow:
  82.             OpenTheOtherMSGWindow(theWindow);
  83.             return kSuccess;
  84.         case kHelpWindow:
  85.             OpenTheHelpWindow(theWindow);
  86.             return kSuccess;
  87.         case kMainWindow:
  88.             OpenTheMainWindow(theWindow);
  89.             return kSuccess;
  90.         case kBuildWindow:
  91.             OpenTheBuildWindow(theWindow);
  92.             return kSuccess;
  93.     }
  94.     
  95.     return kFailure;
  96. }
  97.  
  98. enum DispatchError CloseWindowDispatch(short index)
  99. {
  100.     WindowPtr        theWindow;
  101.     
  102.     theWindow=GetIndWindowPtr(index);
  103.     
  104.     switch (index)
  105.     {
  106.         case kMainWindow:
  107.             if (CloseTheMainWindow(theWindow))
  108.                 return kSuccess;
  109.             else
  110.                 return kCancel;
  111.     }
  112.     
  113.     return kFailure;
  114. }
  115.  
  116. enum DispatchError DisposeWindowDispatch(short index)
  117. {
  118.     WindowPtr        theWindow;
  119.     
  120.     theWindow=GetIndWindowPtr(index);
  121.     
  122.     switch (index)
  123.     {
  124.         case kAboutWindow:
  125.             DisposeTheAboutWindow(theWindow);
  126.             return kSuccess;
  127.         case kOtherMSGWindow:
  128.             DisposeTheOtherMSGWindow(theWindow);
  129.             return kSuccess;
  130.         case kHelpWindow:
  131.             DisposeTheHelpWindow(theWindow);
  132.             return kSuccess;
  133.         case kMainWindow:
  134.             DisposeTheMainWindow(theWindow);
  135.             return kSuccess;
  136.         case kBuildWindow:
  137.             DisposeTheBuildWindow(theWindow);
  138.             return kSuccess;
  139.     }
  140.     
  141.     return kFailure;
  142. }
  143.  
  144. enum DispatchError DrawWindowDispatch(short index, short theDepth)
  145. {
  146.     WindowPtr        theWindow;
  147.     
  148.     theWindow=GetIndWindowPtr(index);
  149.     
  150.     switch (index)
  151.     {
  152.         case kAboutMSGWindow:
  153.             DrawTheAboutMSGWindow(theWindow, theDepth);
  154.             return kSuccess;
  155.         case kHelpWindow:
  156.             DrawTheHelpWindow(theWindow, theDepth);
  157.             return kSuccess;
  158.     }
  159.     
  160.     return kFailure;
  161. }
  162.  
  163. enum DispatchError ChangeDepthDispatch(short index, short newDepth)
  164. {
  165.     WindowPtr        theWindow;
  166.     
  167.     theWindow=GetIndWindowPtr(index);
  168.     
  169.     switch (index)
  170.     {
  171.         case kAboutMSGWindow:
  172.             ChangeDepthTheAboutMSGWindow(theWindow, newDepth);
  173.             return kSuccess;
  174.     }
  175.     
  176.     return kFailure;
  177. }
  178.  
  179. enum DispatchError CopybitsDispatch(short index, WindowPtr offscreenWindow)
  180. {
  181.     WindowPtr        theWindow;
  182.     
  183.     theWindow=GetIndWindowPtr(index);
  184.     
  185.     switch (index)
  186.     {
  187.         case kOtherMSGWindow:
  188.             CopybitsTheOtherMSGWindow(theWindow, offscreenWindow);
  189.             return kSuccess;
  190.         case kMainWindow:
  191.             CopybitsTheMainWindow(theWindow, offscreenWindow);
  192.             return kSuccess;
  193.         case kBuildWindow:
  194.             CopybitsTheBuildWindow(theWindow, offscreenWindow);
  195.             return kSuccess;
  196.     }
  197.     
  198.     return kFailure;
  199. }
  200.  
  201. enum DispatchError IdleWindowDispatch(short index, Point mouseLoc)
  202. {
  203.     WindowPtr        theWindow;
  204.     
  205.     theWindow=GetIndWindowPtr(index);
  206.     
  207.     switch (index)
  208.     {
  209.         case kMainWindow:
  210.             IdleInMainWindow(theWindow, mouseLoc);
  211.             return kSuccess;
  212.     }
  213.     
  214.     return kFailure;
  215. }
  216.  
  217. enum DispatchError ActivateWindowDispatch(short index)
  218. {
  219.     WindowPtr        theWindow;
  220.     
  221.     theWindow=GetIndWindowPtr(index);
  222.     
  223.     switch (index)
  224.     {
  225.         case kOtherMSGWindow:
  226.             GenericActivate(theWindow);
  227.             ActivateTheOtherMSGWindow(theWindow);
  228.             return kSuccess;
  229.         case kMainWindow:
  230.             GenericActivate(theWindow);
  231.             ActivateTheMainWindow(theWindow);
  232.             return kSuccess;
  233.         case kBuildWindow:
  234.             GenericActivate(theWindow);
  235.             ActivateTheBuildWindow(theWindow);
  236.             return kSuccess;
  237.     }
  238.     
  239.     return kFailure;
  240. }
  241.  
  242. enum DispatchError DeactivateWindowDispatch(short index)
  243. {
  244.     WindowPtr        theWindow;
  245.     
  246.     theWindow=GetIndWindowPtr(index);
  247.     
  248.     switch (index)
  249.     {
  250.         case kOtherMSGWindow:
  251.             GenericDeactivate(theWindow);
  252.             DeactivateTheOtherMSGWindow(theWindow);
  253.             return kSuccess;
  254.         case kMainWindow:
  255.             GenericDeactivate(theWindow);
  256.             DeactivateTheMainWindow(theWindow);
  257.             return kSuccess;
  258.         case kBuildWindow:
  259.             GenericDeactivate(theWindow);
  260.             DeactivateTheBuildWindow(theWindow);
  261.             return kSuccess;
  262.     }
  263.     
  264.     return kFailure;
  265. }
  266.  
  267. enum DispatchError GrowWindowDispatch(short index)
  268. {
  269.     WindowPtr        theWindow;
  270.     
  271.     theWindow=GetIndWindowPtr(index);
  272.     
  273.     switch (index)
  274.     {
  275.         case kOtherMSGWindow:
  276.             GenericResizeControls(theWindow, 0);
  277.             return kSuccess;
  278.         case kMainWindow:
  279.             GenericResizeControls(theWindow, 0);
  280.             return kSuccess;
  281.         case kBuildWindow:
  282.             GenericResizeControls(theWindow, 5000);
  283.             return kSuccess;
  284.     }
  285.     
  286.     return kFailure;
  287. }
  288.  
  289. enum DispatchError ZoomWindowDispatch(short index)
  290. {
  291.     WindowPtr        theWindow;
  292.     
  293.     theWindow=GetIndWindowPtr(index);
  294.     
  295.     switch (index)
  296.     {
  297.         case kOtherMSGWindow:
  298.             GenericResizeControls(theWindow, 0);
  299.             return kSuccess;
  300.         case kMainWindow:
  301.             GenericResizeControls(theWindow, 0);
  302.             return kSuccess;
  303.         case kBuildWindow:
  304.             GenericResizeControls(theWindow, 5000);
  305.             return kSuccess;
  306.     }
  307.     
  308.     return kFailure;
  309. }
  310.  
  311. enum DispatchError GetGrowSizeDispatch(short index, Rect *sizeRect)
  312. {
  313.     WindowPtr        theWindow;
  314.     
  315.     theWindow=GetIndWindowPtr(index);
  316.     
  317.     switch (index)
  318.     {
  319.         case kOtherMSGWindow:
  320.             GenericGetGrowSize(theWindow, sizeRect);
  321.             return kSuccess;
  322.         case kMainWindow:
  323.             GenericGetGrowSize(theWindow, sizeRect);
  324.             return kSuccess;
  325.         case kBuildWindow:
  326.             GenericGetGrowSize(theWindow, sizeRect);
  327.             return kSuccess;
  328.     }
  329.     
  330.     return kFailure;
  331. }
  332.  
  333. enum DispatchError KeyDownDispatch(short index, unsigned char theChar)
  334. {
  335.     WindowPtr        theWindow;
  336.     
  337.     theWindow=GetIndWindowPtr(index);
  338.     
  339.     switch (index)
  340.     {
  341.         case kAboutWindow:
  342.             KeyDownInAboutWindow(theWindow, theChar);
  343.             return kSuccess;
  344.         case kOtherMSGWindow:
  345.             GenericKeyPressedInWindow(theWindow, theChar);
  346.             return kSuccess;
  347.         case kHelpWindow:
  348.             KeyPressedInHelpWindow(theWindow, theChar);
  349.             return kSuccess;
  350.         case kMainWindow:
  351.             if (!GenericKeyPressedInWindow(theWindow, theChar))
  352.                 KeyPressedInMainWindow(theWindow, theChar);
  353.             return kSuccess;
  354.         case kBuildWindow:
  355.             if (!GenericKeyPressedInWindow(theWindow, theChar))
  356.                 KeyPressedInBuildWindow(theWindow, theChar);
  357.             return kSuccess;
  358.     }
  359.     
  360.     return kFailure;
  361. }
  362.  
  363. enum DispatchError MouseDownDispatch(short index, Point thePoint)
  364. {
  365.     WindowPtr        theWindow;
  366.     
  367.     theWindow=GetIndWindowPtr(index);
  368.     
  369.     switch (index)
  370.     {
  371.         case kAboutWindow:
  372.             MouseDownInAboutWindow(theWindow, thePoint);
  373.             return kSuccess;
  374.         case kOtherMSGWindow:
  375.             GenericMouseClickedInWindow(theWindow, thePoint, FALSE);
  376.             return kSuccess;
  377.         case kHelpWindow:
  378.             MouseClickedInHelpWindow(theWindow, thePoint);
  379.             return kSuccess;
  380.         case kMainWindow:
  381.             GenericMouseClickedInWindow(theWindow, thePoint, TRUE);
  382.             return kSuccess;
  383.         case kBuildWindow:
  384.             MouseClickedInBuildWindow(theWindow, thePoint);
  385.             return kSuccess;
  386.     }
  387.     
  388.     return kFailure;
  389. }
  390.  
  391. enum DispatchError UndoDispatch(short index)
  392. {
  393.     switch (index)
  394.     {
  395.     }
  396.     
  397.     return kFailure;
  398. }
  399.  
  400. enum DispatchError CutDispatch(short index)
  401. {
  402.     WindowPtr        theWindow;
  403.     
  404.     theWindow=GetIndWindowPtr(index);
  405.     
  406.     switch (index)
  407.     {
  408.         case kMainWindow:
  409.             GenericCut(theWindow);
  410.             return kSuccess;
  411.             break;
  412.     }
  413.     
  414.     return kFailure;
  415. }
  416.  
  417. enum DispatchError CopyDispatch(short index)
  418. {
  419.     WindowPtr        theWindow;
  420.     
  421.     theWindow=GetIndWindowPtr(index);
  422.     
  423.     switch (index)
  424.     {
  425.         case kMainWindow:
  426.             GenericCopy(theWindow);
  427.             return kSuccess;
  428.     }
  429.     
  430.     return kFailure;
  431. }
  432.  
  433. enum DispatchError PasteDispatch(short index)
  434. {
  435.     WindowPtr        theWindow;
  436.     
  437.     theWindow=GetIndWindowPtr(index);
  438.     
  439.     switch (index)
  440.     {
  441.         case kMainWindow:
  442.             PasteInMainWindow(theWindow);
  443.             return kSuccess;
  444.     }
  445.     
  446.     return kFailure;
  447. }
  448.  
  449. enum DispatchError ClearDispatch(short index)
  450. {
  451.     WindowPtr        theWindow;
  452.     
  453.     theWindow=GetIndWindowPtr(index);
  454.     
  455.     switch (index)
  456.     {
  457.         case kMainWindow:
  458.             GenericClear(theWindow);
  459.             return kSuccess;
  460.     }
  461.     
  462.     return kFailure;
  463. }
  464.  
  465. enum DispatchError SelectAllDispatch(short index)
  466. {
  467.     WindowPtr        theWindow;
  468.     
  469.     theWindow=GetIndWindowPtr(index);
  470.     
  471.     switch (index)
  472.     {
  473.         case kMainWindow:
  474.             GenericSelectAll(theWindow);
  475.             return kSuccess;
  476.     }
  477.     
  478.     return kFailure;
  479. }
  480.